//
//  UserAccount.m
//  OC-微博
//
//  Created by Apple on 15/11/10.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "UserAccount.h"
@implementation UserAccount
//- (NSDate *)expiresDate {
//    return  _expiresDate = [[NSDate alloc]initWithTimeIntervalSinceNow:(self.expires_in)];
//}
- (void)setExpires_in:(NSTimeInterval)expires_in {
    _expires_in = expires_in;
self.expiresDate = [[NSDate alloc]initWithTimeIntervalSinceNow:(self.expires_in)];
}
+ (instancetype)initWithdict:(NSDictionary *)dict {
    id user = [UserAccount new];
    [user setValuesForKeysWithDictionary:dict];
    return user;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{}
//描述对象的信息
- (NSString *)description
{
    NSArray *keys = @[@"access_token",@"expires_in",@"uid", @"screen_name",@"avatar_large",@"expiresDate"];
    
    return [self dictionaryWithValuesForKeys:keys].description;
    
}
#pragma mark /*******************  归解档  *******************/
//归档
- (void)encodeWithCoder:(NSCoder *)coder
{ [coder encodeObject:self.access_token forKey:@"access_token"];
    [coder encodeObject:self.expiresDate forKey: @"expiresDate"];
    [coder encodeObject:self.uid forKey: @"uid"];
    [coder encodeObject:self.screen_name forKey: @"screen_name"];
    [coder encodeObject:self.avatar_large forKey: @"avatar_large"];
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self=[super init ]){
        _access_token = [aDecoder decodeObjectForKey:@"access_token"];
        _expiresDate = [aDecoder decodeObjectForKey:@"expiresDate"];
        _uid = [aDecoder decodeObjectForKey:@"uid"];
        _screen_name = [aDecoder decodeObjectForKey:@"screen_name"];
        _avatar_large = [aDecoder decodeObjectForKey:@"avatar_large"];
    }
    return self;
    
}
@end
